import React, { useState, useEffect } from 'react'

export default function Cat () {
  const [position, setPosition] = useState({ x: 0, y: 0 })

  useEffect(() => {
    const move = e => {
      setPosition({
        x: e.clientX,
        y: e.clientY
      })
    }

    window.addEventListener('mousemove', move)

    return () => {
      window.removeEventListener('mousemove', move)
    }
  }, [])

  return (
    <div>
      <img
        src='https://img0.baidu.com/it/u=3974180714,2970977250&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=533'
        alt=''
        style={{
          position: 'absolute',
          left: position.x,
          top: position.y,
          width: 100,
          height: 100
        }}
      />
    </div>
  )
}
